home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / Selection ƒ 2.5 / ptrlist < prev    next >
Encoding:
Text File  |  1994-11-06  |  812 b   |  49 lines  |  [TEXT/MSET]

  1. (*
  2. We will use a ptrlist in class selwindow to dynamically allocate pointers
  3. to objects that we add: to the windows list of objects.  We use Mike's
  4. class for this.
  5. *)
  6.  
  7. :class    PTRLIST  super{ string  sequence }
  8.  
  9. :m ADD:        \ ( ptr -- )
  10.     pad !  pad 4  add: super  ;m
  11.  
  12. :m FIRST?:
  13.     size: super  nif  false  EXIT  THEN        \ No elements - return false
  14.     reset: super  ^1st: super @  true  ;m
  15.  
  16. :m NEXT?:    \ ( -- ptr T  |  -- F )
  17.     4 skip: super  len: super  NIF  false  EXIT  THEN
  18.     ^1st: super  @  true  ;m
  19.     
  20. ;class
  21.  
  22. endload
  23.  
  24. *** EXAMPLE USE
  25.  
  26. ptrlist theList
  27.  
  28. : go
  29.     new: theList
  30.     
  31.     \ these aren't pointers that we're adding here
  32.     \ but this will illustrate what is happening
  33.     12345 add: theList
  34.     67890 add: theList
  35.     33333 add: theList
  36.     BEGIN
  37.         each: theList
  38.     WHILE
  39.         ( item on stack )
  40.         . cr
  41.     REPEAT
  42.     release: theList ;
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.